package tools.Project3.Group3.s12cs342;

import java.util.ArrayList;

import CloudDatabase.Project3.Group3.s12cs342.ReadBlob;
import DataStructures.Project3.Group3.s12cs342.ScoreContainer;
import activities.project3.group3.s12cs342.Quiz;
import android.content.Context;
import android.os.AsyncTask;

public class AsyncGetScore extends AsyncTask <Void, Void, ArrayList<ScoreContainer>>{

	private String username;
	private Context context;
	private String pass;
	
	public AsyncGetScore(String userName, Context context, String pass){
		this.username = userName;
		this.context = context;
		this.pass = pass;
	}
	
	@Override
	protected ArrayList<ScoreContainer> doInBackground(Void... params) {
		return ReadBlob.retrieveBinaryData(username,pass);
	}
	
	
	protected void onPostExecute(ArrayList<ScoreContainer> result){
		
		Quiz myApp = ((Quiz) context.getApplicationContext());
		if(result.isEmpty()){
			System.out.println("Empty");
		}
		ArrayList<String> temp = new ArrayList<String>();
 		while (!result.isEmpty()){
			System.out.println(result.get(0).toString());
			temp.add(result.remove(0).toString());
		}
 		myApp.setS(temp);
		
		
		
	}

}

